<template>
	<view class="warn">
		<view class="contents">
			<view class="control">
				<view class="uni-padding-wrap uni-common-mt">
					<uni-segmented-control :current="current" :values="items" :style-type="station ? 'button' : 'text'"
						:active-color="activeColor" @clickItem="onClickItem" />
				</view>
			</view>
			<view class="content">
				<cardList :reach="reach" ref="list" />
			</view>
		</view>
	</view>
</template>

<script>
	import cardList from "./cardList.vue"
	export default {
		components: {
			cardList,
		},
		props: {
			station: Boolean,
			reach: Boolean
		},
		data() {
			return {
				items: ["发生中", "已恢复"],
				current: 0,
				activeColor: "#007aff",
				abc: '', //表示查询报警状态，1：发生中；0：已解决
			}
		},
		methods: {
			onLeftIcon() {
				console.log("222")
			},
			onClickItem(e) {
				if (e.currentIndex == 0) {
					this.abc = '1'
				} else if (e.currentIndex == 1) {
					this.abc = '0'
				}
				this.$refs.list.getData(this.abc);
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			},
		},
	}
</script>

<style scoped lang="scss">
	.warn {
		background-color: $bg-color;

		.control {
			background-color: #fff;
		}
	}
</style>